import numpy as np
import pandas as pd
from urllib.request import urlopen
import urllib
import os


datas = pd.read_csv('ImageDownLoad/downloadimage3.csv', encoding="gb2312")

# print(datas)
i = 0

j = 0


for img_id in datas['id']:
    # img_face_url = datas['img_face'][j]
    img_one_url = datas['img_one'][j]
    img_two_url =  datas['img_two'][j]
    img_name = datas['name'][j]

    i = 0

    file = "/Users/xieyingze/Desktop/PythonData/"+str(img_name)
    isExists = os.path.exists(file)
    if not isExists:
        os.makedirs(file)

    # path = str(img_name)+'_'+str(i)+'.jpg'
    # print(img_face_url)
    # urllib.request.urlretrieve("http://"+img_face_url, file+"/"+path)
    # print('completed')

    i=1
    path = str(img_name)+'_'+str(i)+'.jpg'
    print(img_one_url)
    urllib.request.urlretrieve("http://"+img_one_url, file+"/"+path)
    print('completed')

    i=2
    path = str(img_name)+'_'+str(i)+'.jpg'
    print(img_two_url)
    urllib.request.urlretrieve("http://"+img_two_url, file+"/"+path)
    print('completed')

    j+=1
    
    